package com.voicechat.firstmet.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;


/**
 * @author Android
 * 录音倒计时 工具类
 */

public class RecordTimerUtil extends CountDownTimer {
    TextView mTextView;
    Context context;
    long nowTime;
    private String TAG = "RecordTimerUtil";
    public boolean isSure;

    public RecordTimerUtil(long countDownTime, TextView textView, Context context) {
        super(countDownTime * 1000, 1000);
        this.context = context;
        mTextView = textView;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        nowTime = millisUntilFinished / 1000;
        /*if( 60 - nowTime <= 5){
            mTextView.setText("60");
        }else {*/
            mTextView.setText(nowTime+"");
        //}

    }

    @Override
    public void onFinish() {
        this.cancel();
        //Log.i(TAG, "onFinish: ----------"+nowTime);
        if( 60 - nowTime <= 5){
            mTextView.setText("60");
        }else {
            if(!isSure) {
                mTextView.setText(nowTime + "");
            }else {
                mTextView.setText("60");
            }
        }
    }




}
